//
//  AIFGetSmsCodeByUsernameManager.m
//  PywSdk
//
//  Created by smallwave on 16/10/11.
//  Copyright © 2016年 zero. All rights reserved.
//

#import "AIFGetSmsCodeByUsernameManager.h"

@implementation AIFGetSmsCodeByUsernameManager

NSString *const GetSmsCodeByUsername_USERNAME = @"username";
NSString *const GetSmsCodeByUsername_TID = @"tid";
NSString *const GetSmsCodeByUsername_GAMEID = @"gameid";
NSString *const GetSmsCodeByUsername_SIGN = @"sign";
NSString *const GetSmsCodeByUsername_SMSTYPE = @"smstype";

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.child = self;
        self.paramSource = self;
        self.validate = self;
    }
    return self;
}


#pragma mark - ETAPIManager
- (NSString *)methodName{
    return URL_GETSMSCODEBYUSERNAME;
}

- (ETAPIManagerRequestType)requestType{
    return ETAPIManagerRequestTypePost;
}


- (NSString *)seriviceType{
    return [PywAppInfo sharedAppInfo].seriviceType;
}

#pragma mark - ETAPIManagerParamSourceDelegate
- (NSDictionary *)paramsForApi:(ETApiBaseManager *)manager{
    NSString *tid = [PywAppInfo sharedAppInfo].tid;
    
    NSString *gameid = [PywAppInfo sharedAppInfo].gameId;
    NSString *username = self.username;
    NSString *apiSecret2 = [AppUtil getApiSecret2:tid apiSecret:[PywAppInfo sharedAppInfo].apisecret];
    
    NSString *sign = [NSString stringWithFormat:@"%@%@%@", gameid, username, apiSecret2];
    sign = [PywCipherUtils md5:sign];
    
    NSString *smsType = self.smsType;
    
    MutableDictionary *param = [[MutableDictionary alloc] init];
    [param setObject:username forKey:GetSmsCodeByUsername_USERNAME];
    [param setObject:tid forKey:GetSmsCodeByUsername_TID];
    [param setObject:gameid forKey:GetSmsCodeByUsername_GAMEID];
    [param setObject:sign forKey:GetSmsCodeByUsername_SIGN];
    [param setObject:smsType forKey:GetSmsCodeByUsername_SMSTYPE];
    return param;
}

#pragma mark - ETAPIManagerValidator
- (BOOL)manager:(ETApiBaseManager *)manager isCorrectWithParamsData:(NSDictionary *)data{
    return YES;
}

- (BOOL)manager:(ETApiBaseManager *)manager isCorrectWithCallBackData:(NSDictionary *)data{
    return YES;
}

@end
